function ActivityController(calendarViewBody, activityIcons) {
    this._calendarViewBody = calendarViewBody;
    this._activityIcons = activityIcons;
}

ActivityController.prototype = {
    register: function(calendar) {
        this._activityMode = new ActivityMode(calendar);
        var me = this;
        var registerEventHandler = function(icon) {
            icon.onClick(function() {
                icon.activate();
                me._activityMode.setActivity(icon.getData());
                me._calendarViewBody.setMode(me._activityMode);
            });
        };
        this._activityIcons.foreach(registerEventHandler);
    }
};

function ActivityMode(calendar) {
    this._calendar = calendar;
    this.cursor = 'calendar-paint-cursor';
    this._activity = null;
}

ActivityMode.prototype = {
    setActivity: function(activity) {
        this._activity = activity;
    },
    onSelection: function(sender, e) {
        var me = this;
        var dateRange = e.data.dateRange;
        this._calendar.beginTransaction();
        var dayModels = dateRange.toDayArray().select(function(date) {
            return me._calendar.getDay(date);
        });
        var action = new ActivityAction(dayModels, this._activity);
        this._calendar.applyAction(action);

        if (dayModels.length == 1) {
            googleAnalyser.trackPageView('/FillSingleActivity')
        }
        else {
            googleAnalyser.trackPageView('/DragFillActivity')
        }
    }
};




